package com.shujia.wyh.day21;

import java.util.Comparator;

public class MyComparator implements Comparator<Student4> {
    @Override
    public int compare(Student4 o1, Student4 o2) {
        int i = o1.getName().compareTo(o2.getName());
        //姓名一样，年龄不一定一样
        int i2 = (i == 0) ? o1.getAge() - o2.getAge() : i;
        return i2;
    }
}
